<template>
	<view class="">
		<scroll-view scroll-x :style="{ backgroundColor: '#fff' }">
			<view class="tabs-box">
				<view v-for="(item, index) in tabList" :key="index"
					:class="['tabs-item', activeName === item.value ? 'active-item' : '']" @click="clickTabsItem(item)">
					<view class="item">{{ item.label }}</view>
					<view v-if="activeName === item.value" class="bottom-line"></view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name: "tabList",
		data() {
			return {
				activeName: ''
			}
		},
		props: {
			tabActive: {
				type: [Number, String],
				default: ''
			},
			tabList: {
				type: Array,
				default: []
			}
		},
		watch: {
		},
		created() {
			this.heightConfig = this.$store.getters.heightData;
			this.scrollHeight = this.heightConfig.mainSearchHeight - 210 + "px"
			this.activeName = this.tabActive
		},
		methods: {
			clickTabsItem(item) {
				this.activeName = item.value
				this.$emit('clickTabsItem', item)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tabs-box {
		position: relative;
		display: flex;
		align-items: center;
		height: 50px;
		padding: 0 28rpx;
		background-color: #fff;
		color: #333333;

		.tabs-item {
			display: flex;
			justify-content: center;
			align-items: center;
			margin: 0 28rpx;
			min-width: 120rpx;
			font-size: 30rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
		}

		.active-item {
			font-weight: bold;
			font-size: 32rpx;
		}

		.bottom-line {
			position: absolute;
			bottom: 0;
			width: 80rpx;
			height: 6rpx;
			background: #333333;
			border-radius: 3rpx;
		}
	}
</style>